// // //+--------------------------+ //| BollTrade Indicator v05a //+--------------------------+ // // #property copyright "Ron Thompson" #property link "http://www.lightpatch.com/forex/" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 White #property indicator_color2 White #property indicator_color3 White #property indicator_color4 Gray #property indicator_color5 Gray #property indicator_color6 White #property indicator_color7 LimeGreen #property indicator_color8 Red extern int BPeriod = 15; // Bollinger period extern double Deviation = 1.8; // Bollinger deviation extern double BDistance = 14; // plus how much extern double ProfitMade = 8; extern double LossLimit = 9; extern bool UseATR = false; extern int ATR_Period = 4; extern double ATR_BDistanceMult = 1.4; extern double ATR_LossLimitMult = 3.6; extern double ATR_ProfitMadeMult= 0.8; //---- buffers int mybars=1000; double BollMA[1000]; double BollUpper[1000]; double BollLower[1000]; double UpperPlus[1000]; double LowerPlus[1000]; double BuySell[1000]; double TP[1000]; double SL[1000]; //+----------------+ //| Custom init | //+----------------+ int init() { // 233 up arrow // 234 down arrow // 159 big dot // 158 little dot // 168 open square // 120 box with X IndicatorBuffers(8); SetIndexStyle(0,DRAW_LINE); //bollinger ma SetIndexArrow(0,158); SetIndexBuffer(0,BollMA); SetIndexStyle(1,DRAW_LINE); //bollinger upper SetIndexArrow(1,158); SetIndexBuffer(1,BollUpper); SetIndexStyle(2,DRAW_LINE); //bollinger lower SetIndexArrow(2,158); SetIndexBuffer(2,BollLower); SetIndexStyle(3,DRAW_LINE); //upperplus SetIndexArrow(3,158); SetIndexBuffer(3,UpperPlus); SetIndexStyle(4,DRAW_LINE); //lowerplus SetIndexArrow(4,168); SetIndexBuffer(4,LowerPlus); SetIndexStyle(5,DRAW_ARROW); //buysell SetIndexArrow(5,168); SetIndexBuffer(5,BuySell); SetIndexStyle(6,DRAW_ARROW); //TP SetIndexArrow(6,120); SetIndexBuffer(6,TP); SetIndexStyle(7,DRAW_ARROW); //SL SetIndexArrow(7,120); SetIndexBuffer(7,SL); } //+----------------+ //| Custom DE-init | //+----------------+ int deinit() { Print("DE-Init happened ",CurTime()); Comment(" "); } //+-----+ //| TPB | //+-----+ int start() { int i; double stddev; double bup0; double bdn0; double myBDistance; double myATR; double myProfitMade; double myLossLimit; for (i=mybars; i>=0; i--) { // Bollinger moving average BollMA[i] = iMA(Symbol(),0,BPeriod,0,MODE_SMA,PRICE_OPEN,i); // upper & lower bands stddev = iStdDev(Symbol(),0,BPeriod,0,MODE_SMA,PRICE_OPEN,i); BollUpper[i] = BollMA[i] + (Deviation*stddev); //upper BollLower[i] = BollMA[i] - (Deviation*stddev); //lower // buy/sell limit cross if(UseATR) { myATR=iATR(Symbol(),0,ATR_Period,i); // expressed as .xxxx myBDistance = (ATR_BDistanceMult * myATR); // so doesn't need Point UpperPlus[i] = BollUpper[i]+(myBDistance); //upperplus LowerPlus[i] = BollLower[i]-(myBDistance); //lowerplus } else { myBDistance=BDistance; UpperPlus[i] = BollUpper[i]+(myBDistance*Point); //upperplus LowerPlus[i] = BollLower[i]-(myBDistance*Point); //lowerplus } if( High[i]>=UpperPlus[i]) { BuySell[i]=UpperPlus[i]; //SELL if(UseATR) { TP[i]=UpperPlus[i]-(myATR*ATR_ProfitMadeMult); SL[i]=UpperPlus[i]+(myATR*ATR_LossLimitMult); } else { TP[i]=UpperPlus[i]-(ProfitMade*Point); SL[i]=UpperPlus[i]+(LossLimit*Point); } } if( Low[i]<=LowerPlus[i]) { BuySell[i]=LowerPlus[i]; //BUY if(UseATR) { TP[i]=LowerPlus[i]+(myATR*ATR_ProfitMadeMult); SL[i]=LowerPlus[i]-(myATR*ATR_LossLimitMult); } else { TP[i]=LowerPlus[i]+(ProfitMade*Point); SL[i]=LowerPlus[i]-(LossLimit*Point); } } }//for }//start